<?php
// +----------------------------------------------------------------------
// | ManniuRead
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://manniuyun.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: heitao <read@manniuyun.com>
// +----------------------------------------------------------------------

/**
 * 获取汉字拼音类
 */
namespace app\api\controller;

use manniu\controller\Base;

class Pinyin extends Base{
	/**
     * 初始化
     */
    public function _initialize() {
        parent::_initialize();
        if(!$this->uid && !$this->aid){
            $this->error('请登录后再执行相关操作','/');
        }
    }

    /**
     * 汉字转换拼音
     */
    public function toPinyin() {
        $name = $this->request->param('name');
        if(!$name){
            return '';
        }
        $pinyin = new \manniu\tools\Pinyin;
        return $pinyin->result($name);
    }
}